package com.azt.provider.model;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.azt.api.enums.EnquiryProstateEnum;

public enum ExcelType {
	COMMON(0, "通用分析", false), COMPANY(1, "新点行业软件解析", false),DONGDAJINZHI(2,"东大金智",false);

	private int index;
	private String title;
	private boolean selected;

	private static List<ExcelType> PROSTATELIST = null;
	private static Map<String, String> PROSTATEMAP = null;

	private ExcelType(int index, String title, boolean selected) {
		this.index = index;
		this.title = title;
		this.selected = selected;
	}

	/**
	 * 获取列表
	 * 
	 * @return
	 * @author 张栋 2016年5月16日下午1:47:23
	 */
	public static List<ExcelType> getStateList(ExcelType selected) {
		if (PROSTATELIST == null) {
			ExcelType[] values = ExcelType.values();
			for (int i = 0; i < values.length; i++) {
				ExcelType excelType = values[i];
				if(excelType.getIndex() == selected.getIndex()){
					excelType.setSelected(true);
				}
			}
			PROSTATELIST = Arrays.asList(values);
		}
		return PROSTATELIST;
	}

	/**
	 * 获取所有状态 code ,title
	 * 
	 * @return
	 */
	public static Map<String, String> getAllStates() {
		if (PROSTATEMAP == null) {
			Map<String, String> allroles = new HashMap<String, String>();
			EnquiryProstateEnum[] values = EnquiryProstateEnum.values();
			for (EnquiryProstateEnum c : values) {
				allroles.put(c.getIndex() + "", c.getTitle());
			}
			PROSTATEMAP = allroles;
		}
		return PROSTATEMAP;
	}

	public static String getTitleByIndex(int index) {
		for (ExcelType c : ExcelType.values()) {
			if (c.getIndex() == index) {
				return c.title;
			}
		}
		return null;
	}

	public int getIndex() {
		return index;
	}

	public void setIndex(int index) {
		this.index = index;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public boolean isSelected() {
		return selected;
	}

	public void setSelected(boolean selected) {
		this.selected = selected;
	}

}
